php[architect] - February 2016 by php
Author:php[architect] & php[architect]
Language: eng
Format: epub
Publisher: php[architect]
Published: 2016-02-03T16:00:00+00:00
The Symfony Event Dispatcher
The Symfony Event Dispatcher implements the Mediator pattern, providing the means to decouple producers and consumers.
In Symfony, the consumers are referred to as listeners. Listeners are callables 3. They can be objects or functions.
The component at its core defines two interfaces, the EventDispatcherInterface and the EventSubscriberInterface, and a class called Event.
The EventDispatcherInterface has methods to add, remove, get, and check for existing listeners. In addition to these, the interface also defines a method to dispatch events, and two methods to add and remove subscribers; see Listing 3. A subscriber is a specialized listener that must implement the EventSubscriberInterface, which we will learn more about later.
Listing 3: Event Dispatcher Interface
<?php namespace Symfony\Component\EventDispatcher; interface EventDispatcherInterface { public function dispatch($eventName, Event $event = null); public function addListener($eventName, $listener, $priority = 0); public function addSubscriber( EventSubscriberInterface $subscriber); public function removeListener($eventName, $listener); public function removeSubscriber( EventSubscriberInterface $subscriber); public function getListeners($eventName = null); public function hasListeners($eventName = null); }
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Whiskies (Collins Gem) by dominic roskrow(45553)
Spell It Out by David Crystal(36257)
Cecilia; Or, Memoirs of an Heiress — Volume 1 by Fanny Burney(32752)
Cecilia; Or, Memoirs of an Heiress — Volume 2 by Fanny Burney(32113)
Cecilia; Or, Memoirs of an Heiress — Volume 3 by Fanny Burney(32094)
Beautiful Disaster by McGuire Jamie(25477)
Trainspotting by Irvine Welsh(22031)
Chic & Unique Celebration Cakes by Zoe Clark(20182)
The Secret History by Donna Tartt(19516)
How High Can a Kangaroo Hop? by Jackie French(18863)
Twilight of the Idols With the Antichrist and Ecce Homo by Friedrich Nietzsche(18796)
All the Missing Girls by Megan Miranda(16837)
Cat's cradle by Kurt Vonnegut(15589)
Ready Player One by Cline Ernest(15177)
For the Love of Europe by Rick Steves(15001)
Fifty Shades Freed by E L James(13374)
4 3 2 1: A Novel by Paul Auster(12644)
Crooked Kingdom: Book 2 (Six of Crows) by Bardugo Leigh(12473)
Grundlagen Kreatives Schreiben (German Edition) by Helfferich Pia(10529)